var webpack = require("webpack");
var path = require('path');
var ROOT_PATH = path.resolve(__dirname);
var ASSETS_PATH = path.resolve(ROOT_PATH, 'assets');
var PUBLIC_PATH = path.resolve(ROOT_PATH, 'public');

module.exports = {
    entry: {
        // "vendor": path.resolve(ASSETS_PATH, 'vendor'),
        "userRegister": path.resolve(ASSETS_PATH, 'user-register/user-register.main'),
        // "index":path.resolve(ASSETS_PATH, "indexMain")
    },
    output: {
        path: ROOT_PATH,
        filename: "public/dist/[name].bundle.js",
        publicPath: "/public/dist/"
    },
    resolve: {
        extensions: ['', '.js', '.ts']
    },
    // devtool: 'source-map',
    module: {
        loaders: [
            {
                test: /\.ts$/,
                loaders: [
                    'ts-loader',
                    'angular2-template-loader',
                    'angular2-router-loader'
                ],
                exclude: /node_modules/
            },
            {
                test: /\.html$/,
                loaders: ['html-loader'],
                exclude: /node_modules/
            },
            {
                test: /\.css$/,
                loaders: ["css-to-string-loader", "css"],
                exclude: /node_modules/
            },
            {test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192'} // inline base64 URLs for <=8k images, direct URLs for the rest
            , {
                test: /\.scss$/,
                // loaders: ["css-to-string-loader", "css", "sass"],
                loaders: "style!css!sass?includePaths[]=" + path.resolve(__dirname, "./node_modules/compass-mixins/lib"),
                exclude: /node_modules/
            }
        ]
    },
    // plugins: [
    //     new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* filename= */"./public/dist/vendor.bundle.js")
    // ],
    devServer: {
        hot: true,
        inline: true,
        contentBase: "./public/",
        // publicPath: ASSETS_PATH,
        port: 9090,
        historyApiFallback: true
    }
};